package com.jucai.pppeiyouclient.view.activity;

import android.Manifest;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.widget.ContentLoadingProgressBar;
import android.text.TextUtils;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;

import com.alipay.sdk.app.PayTask;
import com.jucai.pppeiyouclient.MainActivity;
import com.jucai.pppeiyouclient.R;
import com.jucai.pppeiyouclient.base.BaseActivity;
import com.jucai.pppeiyouclient.base.BaseApplication;
import com.jucai.pppeiyouclient.base.PermissionListener;
import com.jucai.pppeiyouclient.comm.CommonRequestNetData;
import com.jucai.pppeiyouclient.service.PoLocationService;
import com.jucai.pppeiyouclient.utils.ActivityCollector;
import com.jucai.pppeiyouclient.utils.AnimUtil;
import com.jucai.pppeiyouclient.utils.LogUtils;
import com.jucai.pppeiyouclient.utils.LoginUtils;
import com.jucai.pppeiyouclient.utils.PayResult;
import com.jucai.pppeiyouclient.utils.PhoneController;
import com.jucai.pppeiyouclient.utils.SharedPreferencesUtil;
import com.jucai.pppeiyouclient.utils.ToastUtils;

import org.json.JSONException;
import org.json.JSONObject;

import java.net.URLDecoder;
import java.util.HashMap;
import java.util.List;

import cn.sharesdk.onekeyshare.OnekeyShare;
import io.rong.imkit.RongIM;

public class CommonH5Activity extends BaseActivity {
    private static final String TAG = "CommonH5Activity : ";
    private static final int SDK_PAY_FLAG = 1001;
    private WebView commH5Web;
    private ProgressDialog progressDialog;
    private TextView title;

    private int type = 0;
    private String activityId = "";
    private String orderId = "";
    private String activityTitle = "";
    private String tReceiverId = "";
    private String userId = "";

    private String commonId = "";
    private String jumpService = "";
    private String phone = "";
    private String memberId = "";

    private String orderSn = "";
    private String receiverId = "";

    private String activityType = "";
    private String complaintId = "";

    private String aliPayInfo = "";
    private String jumpUrl = "";

    private String order_id = "";

    private boolean isPause, isFindPay;//发现支付

    private String url;

    private ContentLoadingProgressBar mainProgressBar;


    @Override
    protected void onResume() {
        super.onResume();
        if (isPause && !isFindPay) {
            isPause = false;
        }
    }

    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case SDK_PAY_FLAG:
                    PayResult payResult = new PayResult((String) msg.obj);
                    String resultStatus = payResult.getResultStatus();

                    if (TextUtils.equals(resultStatus, "9000")) {
                        ToastUtils.showToast("支付成功");
                    } else {
                        ToastUtils.showToast("支付失败");
                    }
                    LogUtils.e(TAG + "jumpUrl = " + jumpUrl);
                    CommonH5Activity.startCommH5(CommonH5Activity.this, 1001, jumpUrl, null, null, null);
                    ActivityCollector.removeActivity(CommonH5Activity.this);
                    break;
                default:
                    break;
            }
        }
    };

    @Override
    protected void initView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_common_h5);
        mainProgressBar = (ContentLoadingProgressBar) findViewById(R.id.main_progressB_bar);

        commH5Web = (WebView) findViewById(R.id.comm_h5_web);
        title = (TextView) findViewById(R.id.common_title_text);
        progressDialog = new ProgressDialog(CommonH5Activity.this);
        progressDialog.setCanceledOnTouchOutside(false);
        progressDialog.setMessage("正在努力加载，请稍后...");
    }

    @Override
    protected void initData() {
        activityId = getIntent().getStringExtra("activity_id");
        activityTitle = getIntent().getStringExtra("activity_title");
        orderId = getIntent().getStringExtra("order_id");
        type = getIntent().getIntExtra("type", 0);

        LogUtils.e(TAG + "activityId = " + activityId + ",orderId = " + orderId + ",type = " + type);

        if (type == 0) {
            title.setText("活动详情");
        } else if (type == 1) {
            title.setText("接单详情");
        } else if (type == 2) {
            title.setText("用户详情");
        } else if (type == 3) {
            title.setText("红包大厅");
        } else {
            title.setVisibility(View.INVISIBLE);
        }

        commH5Web.loadUrl(getIntent().getStringExtra("url"));
        url = getIntent().getStringExtra("url");
        LogUtils.e(TAG + "url = " + getIntent().getStringExtra("url"));

        commH5Web.setHorizontalScrollBarEnabled(false);
        commH5Web.setVerticalScrollBarEnabled(false);
        WebSettings webSettings = commH5Web.getSettings();
        webSettings.setSupportZoom(true);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setBuiltInZoomControls(true);
        webSettings.setUseWideViewPort(true);
        webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);

        commH5Web.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                super.onPageStarted(view, url, favicon);

            }

            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
            }

            @Override
            public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
                String data = "网络加载错误，请检查网络连接是否正常！";
                view.loadUrl("javascript:document.body.innerHTML=\"" + data + "\"");
            }
        });


        commH5Web.setWebChromeClient(new WebChromeClient() {

            @Override
            public void onProgressChanged(WebView view, int progress) {
                mainProgressBar.setProgress(progress);
                if (progress == 100) {
                    if (mainProgressBar.getVisibility() == View.VISIBLE) {
                        AnimUtil.goneAlpha(mainProgressBar);
                    }
                    mainProgressBar.setVisibility(View.GONE);
                } else {
                    if (mainProgressBar.getVisibility() == View.GONE) {
                        AnimUtil.showAlpha(mainProgressBar);
                    }
                    mainProgressBar.setVisibility(View.VISIBLE);
                }
                super.onProgressChanged(view, progress);
            }


            @Override
            public void onReceivedTitle(WebView view, String title) {
            }

            @Override
            public boolean onJsAlert(WebView view, String url, String message, JsResult result) {

                return super.onJsAlert(view, url, message, result);
            }

            @Override
            public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
                return super.onJsConfirm(view, url, message, result);
            }

            @Override
            public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
                return super.onJsPrompt(view, url, message, defaultValue, result);
            }

        });
        commH5Web.addJavascriptInterface(new JavaScriptInterface(), "AndroidFunction");
    }

    @Override
    protected void loadNetData() {

    }

    @Override
    protected void setListener() {
        findViewById(R.id.common_back).setOnClickListener(this);
        findViewById(R.id.common_home_back).setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.common_back:
                // ActivityCollector.removeActivity(this);
                exit();
                break;
            case R.id.common_home_back:
                startActivity(new Intent(CommonH5Activity.this, MainActivity.class));
                ActivityCollector.removeActivity(this);
                break;
        }
    }

    /**
     * 退出时产生的动画
     */
    private void exit() {
        if (commH5Web.canGoBack()) {
            commH5Web.goBack();
        } else {
            finish();
            //overridePendingTransition(R.anim.tran_previous_in,
            //      R.anim.tran_previous_out);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (BaseApplication.targetMemberId != null)
            BaseApplication.targetMemberId = null;
    }

    public static void startCommH5(Context context, int type, String url, String activityId, String orderId,
                                   String activityTitle) {
        Intent intent = new Intent(context, CommonH5Activity.class);
        intent.putExtra("type", type);
        intent.putExtra("url", url);
        intent.putExtra("activity_id", activityId);
        intent.putExtra("order_id", orderId);
        intent.putExtra("activity_title", activityTitle);
        context.startActivity(intent);
    }

    class JavaScriptInterface {
        @JavascriptInterface
        public void showToast(String webMessage) {
            LogUtils.e(TAG + "onJsConfirm -->" + webMessage);
//            if (webMessage.contains("service=Conductor_Activity.getapplylist")) {
//                ToastUtils.showToast("系统错误!");
//                return;
//            }
            String[] info = webMessage.split("&");
            for (int i = 0; i < info.length; i++) {
                String temp = info[i];
                String[] temp2 = temp.split("=");

                if (temp2[0].equals("order_id")) {
                    order_id = temp2[1];
                }

                if (temp2[0].equals("id")) {
                    commonId = temp2[1];
                }

                if (temp2[0].equals("treceive_id")) {
                    tReceiverId = temp2[1];
                }

                if (temp2[0].equals("user_id")) {
                    userId = temp2[1];
                }

                if (temp2[0].equals("service")) {
                    jumpService = temp2[1];
                }

                if (temp2[0].equals("telephone")) {
                    phone = temp2[1];
                }

                if (temp2[0].equals("torder_ordersn")) {
                    orderSn = temp2[1];
                }

                if (temp2[0].equals("recevier_id")) {
                    receiverId = temp2[1];
                }

                if (temp2[0].equals("member_id")) {
                    memberId = temp2[1];
                }

                if (temp2[0].equals("tactivity_type")) {
                    activityType = temp2[1];
                }

                if (temp2[0].equals("tcompain_receiver_id")) {
                    complaintId = temp2[1];
                }

                if (temp2[0].equals("alipay_sdk")) {
                    aliPayInfo = temp2[1];
                }

                if (temp2[0].equals("jumpUrl")) {
                    jumpUrl = URLDecoder.decode(temp2[1]);
                }

                if (type == 5) {
                    if (webMessage.contains("Find_Order.buy")) {
                        if (TextUtils.equals(temp2[0], "goods_id")) {
                            goods_id = temp2[1];
                        } else if (TextUtils.equals(temp2[0], "sellerid")) {
                            sellerid = temp2[1];
                        } else if (TextUtils.equals(temp2[0], "cateid")) {
                            cateid = temp2[1];
                        } else if (TextUtils.equals(temp2[0], "find_type")) {
                            find_type = temp2[1];
                        } else if (TextUtils.equals(temp2[0], "startDate")) {
                            startDate = temp2[1];
                        } else if (TextUtils.equals(temp2[0], "endDate")) {
                            endDate = temp2[1];
                        }
                    }
                }

            }

            switch (jumpService) {
                case "Conductor_Activity.getapplylist":
                    jumpUserList();
                    break;
                case "Conductor_Activity.appendContent":
                    jumpAppend();
                    break;
                case "Client_Yueqi.yueqi_agree":
                case "Conductor_Order.reject":
                    jumpYueQiCommon();
                    break;
                case "Conductor_Order.getuserinfo":
                    jumpUserInfo();
                    break;
                case "Conductor_Order.receive":
                    commonJumpOrders(jumpService, commonId);
                    break;
                case "Conductor_Activity.cancelactivity":
                    commonJump(jumpService, commonId);
                    jumpActivities();
                    break;
                case "Conductor_Activity.endActivity":
                    commonJump(jumpService, commonId);
                    jumpActivities();
                    break;
                case "Conductor_Order.cancelorder":
                    commonJump(jumpService, commonId);
                    jumpHisOrder();
                    break;
                case "Conductor_Order.closeservice":
                    Intent intent = new Intent(CommonH5Activity.this, PoLocationService.class);
                    //stopService(intent);
                    intent.putExtra("order_id", orderId);
                    intent.putExtra("order_id_type",1);
                    startService(intent);
                    commonJump(jumpService, commonId);
                    jumpHisOrder();
                    break;
                case "Conductor_Person.getlist":
                    jumpTravelRecord();
                    break;
                case "call":
                    jumpTel();
                    break;
                case "Client_Evaluate.evaluate":
                    jumpEvaluate();
                    break;

                case "Client_Compain.tousu":
                    jumpComplaint();
                    break;

                case "Conductor_Activity.showActivityEvaluation":
                    jumpActEvaluations();
                    break;

                case "OpenRongyun":
                    toRongyunChat();
                    break;

                case "Conductor_Order.startservice":
                    jumpStartService();
                    break;

                case "SellerOrderPay":
                    zfbPay(aliPayInfo);
                    break;
                case "Find_Order.buy":
                    jumpFindCommodityPay();
                    break;

                case "Find_Order.cancelOrder":
                    cancelFindOrder();
                    break;
                case "service=call":
                    PhoneController.call(CommonH5Activity.this, phone);
                    break;
                case "Client_Wallet.recharge":
                    Intent iWalletDeatil = new Intent(CommonH5Activity.this,WalletDetailActivity.class);
                    startActivity(iWalletDeatil);
                    break;
                default:
                    commonJump(jumpService, commonId);
                    break;
            }
        }

        @JavascriptInterface
        public void appFx(String url) {  //分享
            showShare("PP优约服务端", url+"&state=1", url+"&state=1"); //分享功能
//            HashMap<String, String> param = new HashMap<>();
//            param.put("service", "Extension_Qrcode.getQrCode");
//            param.put("member_id", LoginUtils.getMember_id(CommonH5Activity.this));
//            param.put("token", LoginUtils.getToken(CommonH5Activity.this));
//            CommonRequestNetData.getJsonObjectData(CommonH5Activity.this, param, false, new CommonRequestNetData.JsonObjectCallBack() {
//
//                @Override
//                public void parseJsonObject(JSONObject jsonObject) {
//                    try {
//                        //LogUtils.e(TAG + "shareData = " + jsonObject.toString());
//                        String url = jsonObject.getString("url");
//                        //  Toast.makeText(MainActivity.this,url,Toast.LENGTH_SHORT).show();
//                        showShare("title", url, url); //分享功能
//                    } catch (Exception e) {
//                    }
//                }
//            });
        }

        @JavascriptInterface
        public void appFxxx(String imgurl, String title, String contens, String url) {  //分享2
            showShare("PP优约服务端", url+"&state=1", url+"&state=1"); //分享功能

//            showShare(title, url+"&state=1", imgurl); //分享
        }
    }

    private void cancelFindOrder() {
        HashMap<String, String> param = new HashMap<>();
        param.put("service", "Find_Order.cancelOrder");
        param.put("order_id", order_id);
        param.put("member_id", LoginUtils.getMember_id(this));
        param.put("token", LoginUtils.getToken(this));

        CommonRequestNetData.getJsonStringDataByEncrpt(CommonH5Activity.this, param, new CommonRequestNetData.ResultCallBack() {
            @Override
            public void parseJsonString(String str) {
                ToastUtils.showToast("取消成功");
                commH5Web.reload();
            }

            @Override
            public void onError(String str) {
                ToastUtils.showToast("取消成功");

            }
        });
    }

    OnekeyShare oks;

    private void showShare(String text, String url, String imgUrl) {
        if (oks == null)
            oks = new OnekeyShare();
        //关闭sso授权
        oks.disableSSOWhenAuthorize();
        // title标题，印象笔记、邮箱、信息、微信、人人网、QQ和QQ空间使用
        oks.setTitle("PP优约");
        // titleUrl是标题的网络链接，仅在Linked-in,QQ和QQ空间使用
        oks.setTitleUrl(url);
        // text是分享文本，所有平台都需要这个字段
        oks.setText(text);
        //分享网络图片，新浪微博分享网络图片需要通过审核后申请高级写入接口，否则请注释掉测试新浪微博
        oks.setImageUrl(imgUrl);
        // imagePath是图片的本地路径，Linked-In以外的平台都支持此参数
        //oks.setImagePath("/sdcard/test.jpg");//确保SDcard下面存在此张图片
        // url仅在微信（包括好友和朋友圈）中使用
        oks.setUrl(url);
        // comment是我对这条分享的评论，仅在人人网和QQ空间使用
        oks.setComment("");
        // site是分享此内容的网站名称，仅在QQ空间使用
        oks.setSite("PP优约");
        // siteUrl是分享此内容的网站地址，仅在QQ空间使用
        oks.setSiteUrl(url);

        // 启动分享GUI
        oks.show(this);
    }

    String goods_id, sellerid, cateid, find_type, startDate, endDate;

    /**
     * 解析发现支付订单
     */
    private void parseFindOrder() {
        if (!TextUtils.isEmpty(goods_id) && !TextUtils.isEmpty(sellerid) && !TextUtils.isEmpty(cateid) && !TextUtils.isEmpty(find_type)) {
            Intent intent = new Intent();
            intent.setClass(this, FindPayOrderActivity.class);
            if (TextUtils.equals(find_type, "goods"))
                intent.putExtra("type", 0);
            else {
                intent.putExtra("type", 1);
                intent.putExtra("startDate", startDate);
                intent.putExtra("endDate", endDate);
            }
            intent.putExtra("goods_id", goods_id);
            intent.putExtra("sellerid", sellerid);
            intent.putExtra("cateid", cateid);
            intent.putExtra("find_type", find_type);
            startActivityForResult(intent, 1002);
        } else
            ToastUtils.showToast("请刷新页面后重试");
    }

    private void jumpFindCommodityPay() {
        parseFindOrder();
    }

    private void commonJump(String service, String id) {
        HashMap<String, String> param = new HashMap<>();
        param.put("service", service);
        param.put("id", id);
        LogUtils.e(TAG + "param = " + param.toString());

        CommonRequestNetData.getJsonStringDataByEncrpt(CommonH5Activity.this, param, new CommonRequestNetData.ResultCallBack() {
            @Override
            public void parseJsonString(String str) {
                LogUtils.e(TAG + "str = " + str);
                JSONObject jsonObject = null;
                try {
                    jsonObject = new JSONObject(str);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                if (jsonObject != null) {
                    LogUtils.e(TAG + "hasURL = " + jsonObject.has("URL"));
                    if (jsonObject.has("URL")) {
                        try {
                            String toUrl = jsonObject.getString("URL");
                            CommonH5Activity.startCommH5(CommonH5Activity.this, type, toUrl, activityId, orderId, activityTitle);
                            ActivityCollector.removeActivity(CommonH5Activity.this);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }

            }

            @Override
            public void onError(String str) {
                ToastUtils.showToast(str);
            }
        });
    }

    private void commonJumpOrders(String service, String id) {
        HashMap<String, String> param = new HashMap<>();
        param.put("service", service);
        param.put("id", id);
        LogUtils.e(TAG + "param = " + param.toString());

        CommonRequestNetData.getJsonStringDataByEncrpt(CommonH5Activity.this, param, new CommonRequestNetData.ResultCallBack() {
            @Override
            public void parseJsonString(String str) {
                LogUtils.e(TAG + "str = " + str);
                jumpOrders();
            }

            @Override
            public void onError(String str) {
                ToastUtils.showToast(str);
                commH5Web.loadUrl(url);
            }
        });
    }


    private void toRongyunChat() {
        HashMap<String, String> param = new HashMap<>();
        param.put("service", "Public_Chat.getMemberChatId");
        param.put("target_member_id", userId);

        CommonRequestNetData.getJsonObjectData(CommonH5Activity.this, param, true, new CommonRequestNetData.JsonObjectCallBack() {
            @Override
            public void parseJsonObject(JSONObject jsonObject) {
                LogUtils.e(TAG + "jsonObject = " + jsonObject.toString());
                try {
                    String rongyun_id = jsonObject.getString("rongyun_id");
                    if (rongyun_id.equals("") || rongyun_id == null) {
                        ToastUtils.showToast("服务器异常，请稍后再试");
                        return;
                    }
                    String rongyun_avatar = jsonObject.getString("rongyun_avatar");
                    String rongyun_nickname = jsonObject.getString("rongyun_nickname");
                    SharedPreferencesUtil.saveStringPreference(CommonH5Activity.this, "rongyun", "rongyun_nickname", rongyun_nickname);
                    LogUtils.e(TAG + "rongyun_id = " + rongyun_id + " , rongyun_avatar = " + rongyun_avatar + ",rongyun_nickname =" + rongyun_nickname);
                    if (RongIM.getInstance() != null)
                        RongIM.getInstance().startPrivateChat(CommonH5Activity.this, rongyun_id, rongyun_nickname);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });

        BaseApplication.targetMemberId = userId;
    }

    private void jumpStartService() {
        Intent intent = new Intent(CommonH5Activity.this, PoLocationService.class);
        intent.putExtra("order_id", orderId);
        intent.putExtra("order_id_type",2);
        startService(intent);
        commonJump(jumpService, commonId);
    }

    private void jumpHisOrder() {
        MyOrdersActivity.startMyOrders(CommonH5Activity.this, 3);
        ActivityCollector.removeActivity(this);
    }

    private void jumpActEvaluations() {
        ActivityEvaluationsActivity.startActEvaluations(CommonH5Activity.this, activityId);
    }

    private void jumpComplaint() {
        ComplaintActivity.startComplaint(CommonH5Activity.this, orderSn, complaintId, memberId);
        ActivityCollector.removeActivity(this);
    }

    private void jumpEvaluate() {
        EvaluateActivity.startOrderEvaluate(CommonH5Activity.this, orderSn, receiverId, memberId, orderId);
        ActivityCollector.removeActivity(this);
        LogUtils.e(TAG + "receiverId = " + receiverId);
    }

    private void jumpTel() {
        BaseActivity.onRuntimePermissionRequest(new String[]{Manifest.permission.CALL_PHONE}, new PermissionListener() {
            @Override
            public void onGranted() {
                try {
                    Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone));
                    startActivity(intent);
                } catch (SecurityException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onDenied(List<String> deniedPermissions) {

            }
        });

    }

    private void jumpTravelRecord() {
        TravelRecordActivity.startTravelRecord(CommonH5Activity.this, 1, userId);
    }

    private void jumpYueQiCommon() {
        HashMap<String, String> param = new HashMap<>();
        param.put("service", jumpService);
        param.put("id", commonId);
        param.put("treceive_id", tReceiverId);

        CommonRequestNetData.getJsonObjectData(CommonH5Activity.this, param, true, new CommonRequestNetData.JsonObjectCallBack() {
            @Override
            public void parseJsonObject(JSONObject jsonObject) {
                LogUtils.e(TAG + "jsObj = " + jsonObject);
                MyOrdersActivity.startMyOrders(CommonH5Activity.this, 1);
                ActivityCollector.removeActivity(CommonH5Activity.this);
            }
        });

    }


    private void jumpActivities() {
        MyActivitiesActivity.startActivities(CommonH5Activity.this, 1);
        ActivityCollector.removeActivity(this);
    }

    private void jumpOrders() {
        MyOrdersActivity.startMyOrders(CommonH5Activity.this, 0);
        ActivityCollector.removeActivity(this);
    }


    private void jumpUserInfo() {
        HashMap<String, String> param = new HashMap<>();
        param.put("id", commonId);
        param.put("service", jumpService);
        param.put("user_id", userId);
        LogUtils.e("param = " + param.toString());

        CommonRequestNetData.getJsonObjectData(CommonH5Activity.this, param, true, new CommonRequestNetData.JsonObjectCallBack() {
            @Override
            public void parseJsonObject(JSONObject jsonObject) {
                LogUtils.e(TAG + "jsObj = " + jsonObject);
                try {
                    String toUrl = jsonObject.getString("URL");
                    CommonH5Activity.startCommH5(CommonH5Activity.this, type, toUrl, activityId, orderId, activityTitle);
                    ActivityCollector.removeActivity(CommonH5Activity.this);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
    }

    private void jumpAppend() {
        AppendContentActivity.startAppend(CommonH5Activity.this, activityTitle, activityId);
    }

    private void jumpUserList() {
        if (activityType.equals("2")) {
            NegativeEnlistUserActivity.startNegEnlist(CommonH5Activity.this, activityId);
        } else if (activityType.equals("1")) {
            PositiveEnlistUsersActivity.starPosEnlist(CommonH5Activity.this, activityId);
        }
    }

    private void zfbPay(final String orderInfo) {
        Runnable payRunnable = new Runnable() {
            @Override
            public void run() {
                PayTask aliPay = new PayTask(CommonH5Activity.this);
                String result = aliPay.pay(orderInfo, true);
                LogUtils.e(TAG + "SDK 返回：" + result.toString());

                Message message = Message.obtain();
                message.what = SDK_PAY_FLAG;
                message.obj = result;
                mHandler.sendMessage(message);
            }
        };

        Thread payThread = new Thread(payRunnable);
        payThread.start();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 1 && resultCode == 100) {
            setResult(100);
            finish();

        }
        if (requestCode == 1002) {
            if (resultCode == RESULT_OK) {
                isFindPay = true;
                if (!TextUtils.isEmpty(data.getStringExtra("jumpUrl"))) {
                    commH5Web.loadUrl(data.getStringExtra("jumpUrl"));
                } else {
                    commH5Web.reload();
                }
            } else
                isFindPay = false;
        }
    }

}
